<?php
session_start();

if(!isset($_SESSION['userid']))//检查 userid 是否已经设置，如果没有设置，提示未登录并跳转首页
{
    echo "<script>alert('您尚未登录！')</script>";
    echo "<script>window.location.href='index.php'</script>";

}

$userid=$_SESSION['userid'];
include ('mysqli_connect.php');

?>

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>影视管理系统</title>
    <link rel="stylesheet" href="http://cdn.static.runoob.com/libs/bootstrap/3.3.7/css/bootstrap.min.css">
    <script src="http://cdn.static.runoob.com/libs/jquery/2.1.1/jquery.min.js"></script>
    <script src="http://cdn.static.runoob.com/libs/bootstrap/3.3.7/js/bootstrap.min.js"></script>
    <style>
        body{
            width: 100%;
            height:auto;
            overflow: hidden;
            /*background: url("300046-106.jpg") no-repeat;*/
            background-size:cover;
            color: antiquewhite;
        }
        #query{
            text-align: center;
        }
        p{
            max-width: 50%;
            margin: auto;
            text-align:justify;
            color: black;
        }

    </style>
</head>

<body>
<nav class="navbar navbar-default navbar-static-top" role="navigation">
    <div class="container-fluid">
        <div class="navbar-header">
            <a class="navbar-brand" href="#">我的影视库</a>
        </div>
        <div>
            <ul class="nav navbar-nav">
                <!--                <li class="active"><a href="reader_index.php">主页</a></li>-->
                <!--                <li><a href="reader_querybook.php">图书查询</a></li>-->
                <!--                <li><a href="reader_borrow.php">我的借阅</a></li>-->
                <!--                <li><a href="reader_info.php">个人信息</a></li>-->
                <!--                <li><a href="reader_repass.php">密码修改</a></li>-->
                <!--                <li><a href="reader_guashi.php">证件挂失</a></li>-->
                <!--                <li><a href="index.php">退出</a></li>-->
                <!--                <li class="active"><a href="user_index.php">主页</a></li>-->
                <!--                <li><a href="user_querymovie.php">影视查询</a></li>-->
                <!--                <li><a href="user_sheet.php">我的收藏</a></li>-->
                <!--                <li><a href="user_info.php">个人信息</a></li>-->
                <!--                <li><a href="index.php">退出</a></li>-->
                <li><a href="user_index.php">主页</a></li>
                <li class="active"><a href="user_querymovie.php">影视查询</a></li>
                <li><a href="user_sheet.php">我的收藏</a></li>
                <li class="dropdown">
                    <a href="#" class="dropdown-toggle" data-toggle="dropdown">个人信息<b class="caret"></b></a>

                    <ul class="dropdown-menu">
                        <li><a href="user_info.php">用户信息</a></li>
                        <li><a href="user_repass.php">修改密码</a></li>
                    </ul>
                </li>
                <li><a href="index.php">退出</a></li>
            </ul>
        </div>
    </div>
</nav>

<?php
    $movie_id = $_GET['id'];
    $sqla = "select * from movie_information_table where movie_id = '{$movie_id}';";
    $resa = mysqli_query($dbc,$sqla);
    if($resa != false)
    {
        $result = mysqli_fetch_array($resa);
        $movie_name = $result['movie_Chinese_name'];
        $movie_director = $result['movie_director'];
        $movie_regiou = $result['movie_regiou'];
        $release_time = $result['release_time'];
        $movie_language = $result['movie_language'];
        $movie_duration = $result['movie_duration'];
        $movie_English_name = $result['movie_English_name'];
        $movie_marking = $result['movie_marking'];
        $movie_intro = $result['movie_intro'];
    }
    else
    {
        echo "<script>alert('影视不存在！')</script>";
    }
?>

<h1 style = "text-align: center; color: darkblue"><strong><?php echo $movie_name?></strong></h1><br><br>
<p><strong>英文名：</strong><?php echo $movie_English_name?></p>
<p><strong>导演：</strong><?php echo $movie_director?></p>
<p><strong>地区：</strong><?php echo $movie_regiou?></p>
<p><strong>上映年份：</strong><?php echo $release_time?>年</p>
<p><strong>语言：</strong><?php echo $movie_language?></p>
<p><strong>时长：</strong><?php echo $movie_duration?>分钟</p>
<p><strong>平均评分：</strong><?php echo $movie_marking?></p>
<p><strong>简介：</strong><?php echo $movie_intro?></p>
<br><br>

<?php
//    $movie_id = $_GET['id'];
//    $sqlp = "select * from movie1.movie_information_table where movie_id = '{$movie_id}';";
    $sqlp = "select * from user_mark_table where movie_id='{$movie_id}' and user_id='{$userid}';";
    $resp = mysqli_query($dbc,$sqlp);
    $resultp = mysqli_fetch_array($resp);
    if($resultp != false)
    {

        $user_marking = $resultp['user_marking'];
        $marking_content = $resultp['marking_content'];
        $marking_time = $resultp['marking_time'];
    }
    else
    {
        $user_marking = "暂无评分";
        $marking_content = "暂无评语";
        $marking_time = "暂无编辑记录";
//        echo "<script>alert('影视不存在！')</script>";
    }
?>


<p><strong>我的评分：</strong><?php echo $user_marking?></p>
<p><strong>我的评语：</strong><?php echo $marking_content?></p>
<p><strong>最后编辑于：</strong><?php echo $marking_time?></p>
<br>
<?php
    echo "<p><a href='user_change_mark.php?id={$movie_id}'><strong>更新评论</strong></a></p>";
    echo "<br><br>";
    echo "<p><a href='user_add_movie_to_sheet.php?id={$movie_id}'><strong>添加到我的影单</strong></a></p>";

?>